/**
 * Created by chargo on 2014/12/19.
 */
$(function() {
    var speFun = {
        speOfferGoods: document.getElementById('speOfferGoods'),
        navHover: function() {
            $(".spe-offer-nv li").mouseover(function() {
                var index = $(this).index(),
                    dis = 16 +  index * 58;
                $(".spe-offer-box-tab").stop(true, true).animate({
                    "left" : dis + "px"
                },600);
                // if(index >= 0) {
                //     $(".spe-offer-img").stop(true, true).animate({
                //         "opacity" : "0"
                //     },5000,function(){
                //         $(".spe-offer-img").attr("src", "/themes/mmj/assets/images/spe_offer_bg" + index + ".jpg");
                //     });
                //     $(".spe-offer-img").stop(true, true).animate({
                //         "opacity" : "1"
                //     },3000);
                // }
            });
        },
        navClick: function() {
            $(".spe-offer-nv li ").click(function() {
                var index = $(this).index(),
                    dis = 16 + index * 58;
                $(".spe-offer-box-tab").css({
                    "left" : dis + "px"
                });
             if(index >= 0) {
                $(".spe-offer-img").stop(true, true).animate({
                    "opacity" : "0"
                },5000,function(){
                    $(".spe-offer-img").attr("src", "/themes/mmj/assets/images/spe_offer_bg" + index + ".jpg");
                });
                $(".spe-offer-img").stop(true, true).animate({
                    "opacity" : "1"
                },3000);
            }
            })
        },
        navBottomFix: function() {
            var boxWidth = this.speOfferGoods.clientWidth,
                boxLeft = this.speOfferGoods.offsetLeft;
            $(".spe-offer-bNav").css({
                "left" : (boxWidth + boxLeft + 10) + "px"
            });
            $(window).resize(function() {
                var boxWidth = this.speOfferGoods.clientWidth,
                    boxLeft = this.speOfferGoods.offsetLeft;
                $(".spe-offer-bNav").css({
                    "left" : (boxWidth + boxLeft + 10) + "px"
                });
            })
        },
        navBottomToTop: function() {
            $(".spe-offer-bNav").click(function() {
                $("body").animate({
                    "scrollTop" : "0"
                },600);
            });
        },
        imgFix: function() {
           
        },
        bodyHeight: $(document).height(),
        hotClick: function() {
            $(".spe-offer-icon").click(function() {
                $(this).children("div").css({
                    "background" : "url(" + "/themes/mmj/assets/images/icon.png" + ") -79px -259px"
                });
            });

        }
    }
    speFun.navHover();
    speFun.navBottomFix();
    speFun.navBottomToTop();
    // speFun.imgFix();
    speFun.hotClick();
    speFun.navClick();
});
    

    // 加入收藏夹功能
 function AddFavorite(sURL, sTitle)
    {
        try
        {
            window.external.addFavorite(sURL, sTitle);
        }
        catch (e)
        {
            try
            {
                window.sidebar.addPanel(sTitle, sURL, "");
            }
            catch (e)
            {
                alert("加入收藏失败，请使用Ctrl+D进行添加");
            }
        }
    }  
